package xuan.mall.system.infrastructure.persistence.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;
import xuan.mall.system.domain.entity.User;
import xuan.mall.system.domain.repository.UserRepository;
import xuan.mall.system.infrastructure.persistence.mapper.UserMapper;

/**
 * @author: rongxuanzhou
 * @create: 2025/5/31
 * @Description: 系统用户Service实现
 */
@Repository
public class UserRepositoryImpl extends ServiceImpl<UserMapper, User> implements UserRepository {

    /**
     * 根据用户名称查询用户信息
     * @param username 用户名
     * @return 用户
     */
    @Override
    public User findByUsername(String username) {
        return this.baseMapper
                .selectOne(new LambdaQueryWrapper<User>().eq(User::getUsername, username).ne(User::getStatus, "1"));
    }
}
